package com.kwan.x_im.data;


import com.kwan.x_im.data.db.RoomDataSource;
import com.kwan.x_im.data.http.HttpDataSource;
import com.kwan.xframe.mvvm.data.source.http.HttpResult;

import io.reactivex.rxjava3.core.Flowable;

public class AppRepository {

	public static volatile AppRepository instance = null;

	public static AppRepository getInstance() {
		if (instance == null) {
			synchronized (AppRepository.class) {
				if (instance == null) {
					instance = new AppRepository();
				}
			}
		}
		return instance;
	}


	public HttpDataSource mHttpDataSource;

	public RoomDataSource mRoomDataSource;

	private AppRepository() {
		mHttpDataSource = new HttpDataSource();
		mRoomDataSource = new RoomDataSource();
	}

	public Flowable<HttpResult<Object>> checkToken(String idToken) {
		return mHttpDataSource.checkToken(idToken);
	}

	public Flowable<HttpResult<Object>> refreshToken() {
		return mHttpDataSource.refreshToken();
	}

	public Flowable<HttpResult<Object>> orderSn(String googleUserId, String productId) {
		return mHttpDataSource.orderSn(googleUserId,productId);
	}

	public Flowable<HttpResult<Object>> verifyOrder(String jsonData) {
		return mHttpDataSource.verifyOrder(jsonData);
	}

	public Flowable<HttpResult<Object>> purchaseChapter(String googleUserId, String novelId, String chapterIds) {
		return mHttpDataSource.purchaseChapter(googleUserId,novelId,chapterIds);
	}



}
